from typing import Optional

from sqlalchemy import Index, Integer, PrimaryKeyConstraint, String
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

class Base(DeclarativeBase):
    pass


class CasbinRule(Base):
    __tablename__ = 'casbin_rule'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='casbin_rule_pkey'),
        Index('idx_casbin_rule', 'ptype', 'v0', 'v1')
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    ptype: Mapped[Optional[str]] = mapped_column(String(255))
    v0: Mapped[Optional[str]] = mapped_column(String(255))
    v1: Mapped[Optional[str]] = mapped_column(String(255))
    v2: Mapped[Optional[str]] = mapped_column(String(255))
    v3: Mapped[Optional[str]] = mapped_column(String(255))
    v4: Mapped[Optional[str]] = mapped_column(String(255))
    v5: Mapped[Optional[str]] = mapped_column(String(255))
